<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRepositoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(
            'repositories',
            function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('title');
                $table->longText('introduction')->nullable();
                $table->unsignedInteger('user_id')->index()->nullable();
                $table->unsignedTinyInteger('type')->default(0);
                $table->unsignedInteger('sort')->default(0);
                $table->unsignedInteger('parent_id')->nullable();
                $table->unsignedInteger('views')->default(0);
                $table->unsignedInteger('length')->default(0);
                $table->text('url')->nullable();
                $table->timestamps();
                $table->softDeletes();
            }
        );
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('repositories');
    }
}
